<template>
    <section>
        <el-col :span="24">
            <el-form inline>
                <el-form-item>
                    <el-input v-model.trim="form.processing_code" placeholder="加工单号" size="small" clearable></el-input>
                </el-form-item>
                <el-form-item>
                    <el-input v-model.trim="form.sku_code" placeholder="sku" size="small" clearable></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" class="el-icon-search" @click="searchBtn" size="small"
                               :loading="btnLoading">查询
                    </el-button>
                </el-form-item>
            </el-form>
        </el-col>
        <el-col :span="24">
            <el-table :data="data" style="width: 100%" :max-height="tableHeight" v-loading="loading" size="small">
                <el-table-column label="工厂名" align="center" prop="factory_name" show-overflow-tooltip></el-table-column>
                <el-table-column label="加工单号" align="center" prop="processing_code" width="120"></el-table-column>
                <el-table-column label="SKU" align="center" prop="sku_code"></el-table-column>
                <el-table-column label="款名" align="center" prop="type_name" show-overflow-tooltip></el-table-column>
                <el-table-column label="款号" align="center" prop="type_no"></el-table-column>
                <el-table-column label="颜色编码" align="center" prop="color_code" width="90"></el-table-column>
                <el-table-column label="尺码编码" align="center" prop="size_code" width="90"></el-table-column>
                <el-table-column label="添加时间" align="center" prop="createtime" width="135"></el-table-column>
                <el-table-column label="增裁数量" align="center" prop="num" width="90"></el-table-column>
                <el-table-column label="状态" align="center" prop="status" width="90">
                    <template slot-scope="{ row }">
                        <el-tag v-if="row.status==0" type="info" size="mini">待审批</el-tag>
                        <el-tag v-else-if="row.status==1" type="success" size="mini">已通过</el-tag>
                        <el-tag v-else type="danger" size="mini">未通过</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="创建人" align="center" prop="adduser">
                </el-table-column>
            </el-table>
            <!--翻页栏-->
            <div style="margin-top: 4px;overflow: hidden;float: right;">
                <Page :total="total" :current="page" :page-size="limit" show-total @on-change="pageChange"></Page>
            </div>
        </el-col>
    </section>
</template>

<script>

import {rfidAddList} from "@/api/produce/rfid";

export default {
    name: "produce_rfid_add",
    data() {
        return {
            tableHeight: window.innerHeight - 210,
            selectIndex: 0,
            btnLoading: false,
            loading: false,
            page: 1,
            limit: 20,
            total: 0,
            data: [],
            user: {},
            nodeActions: [],

            form: {processing_code: "", sku_code: ""},

        }
    },
    created() {
        this.user = this.$store.getters.user;
        this.nodeActions = this.user.node_actions[this.$route.meta.id] ? this.user.node_actions[this.$route.meta.id] : [];
    },
    methods: {
        //搜索按钮
        searchBtn() {
            this.page = 1;
            this.getData();
        },
        //翻页
        pageChange(page) {
            this.page = page;
            this.getData();
        },
        //获取数据
        getData() {
            let param = {
                page: this.page,
                limit: this.limit
            };
            if(this.form.processing_code){
                param.processing_code = this.form.processing_code;
            }
            if(this.form.sku_code){
                param.sku_code = this.form.sku_code;
            }
            this.loading = true;
            rfidAddList(param).then((res) => {
                this.loading = false;
                this.total = res.data.total;
                this.data = res.data.data;
            }).catch(() => {
                this.loading = false;
            });
        },
    },
    mounted() {
        this.searchBtn();
    }
}
</script>

<style scoped>

</style>
